<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
			<title>事件委托</title>
			
	</head>
	<body>
		<ul>
			<li>1</li>
			<li>1</li>
			<li>1</li>
			<li>1</li>
		</ul>
		
		<script type="text/javascript">
				//事件委托的核心原理:通过给父节点添加事件，利用事件冒泡的原理，触发事件
				//获取ul
				var ul = document.querySelector('ul');
				ul.addEventListener('click',function(e){
					e.target.style.backgroundColor = 'pink';
					console.log(e.target.innerText)
				})
			</script>
	</body>
</html>
